<?php 
	/**
	 * Страница ввода необходимых покупок.
	 * 
	 * @author Костин Алексей Васильевич aka Volt(220)
	 * @copyright Copyright (c) 2010, Костин Алексей Васильевич
	 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public License
	 * @version 1.0
	 * @package HomeMoney
	 */

	/**
	 * Подключение настроек. 
	 */
	require_once("../ini.php");

	$DBCon=SQLDBFactory::getDB();

	$DBCon->select("select ntb.id, item, cat, col, srok, date, prim, status 
		FROM needToBuy as ntb
		LEFT OUTER JOIN goods ON goods.id = ntb.id_good
		LEFT OUTER JOIN categ ON goods.id_cat = categ.id
		LEFT OUTER JOIN srok ON ntb.id_srok = srok.id
		order by status, srok desc, date asc");

	$tbody="";
	while($mas=$DBCon->fetchAssoc()){
		if ($mas["status"]=="Y"){
			$check="checked='checked'";
		}
		else{
			$check="";
		}
		$tbody.= <<< TAB
<tr>
	<td>{$mas["id"]}</td>
	<td>{$mas["item"]}</td>
	<td>{$mas["cat"]}</td>
	<td>{$mas["col"]}</td>
	<td>{$mas["srok"]}</td>
	<td>{$mas["date"]}</td>
	<td>{$mas["prim"]}</td>
	<td><input class='inBaseNeed' type='checkbox' value='{$mas["id"]}' $check /></td>
	<td><input class='delete' type='button' value='Delete' /></td>
</tr>
TAB;
	}  	

	$bodyTpl=new Template(DOCROOT."/Templates/needToBuy.tpl");
	$bodyTpl->tbody=$tbody;

	$pageT="Нужно";
	include (DOCROOT."/pages.php"); 
?>
